local wen__guanxing = fk.CreateSkill {
  name = "wen__guanxing",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["wen__guanxing"] = "惯性",
  [":wen__guanxing"] = "锁定技，弃牌阶段，若你的手牌数大于手牌上限，你多弃置一张手牌。",
}

wen__guanxing:addEffect(fk.EventPhaseStart, {
  anim_type = "discard",

  can_trigger = function(self, event, target, player, data)
    return target == player
    and player:hasSkill(wen__guanxing.name)
    and player.phase == Player.Discard
    and not data.phase_end
  end,

  on_cost = Util.TrueFunc,

  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMaxCards() > 0 and player:getHandcardNum() > player:getMaxCards() then
      local need_discard = player:getHandcardNum() - player:getMaxCards() + 1
      player:broadcastSkillInvoke(wen__guanxing.name)
      room:askToDiscard(player, {
        skill_name = wen__guanxing.name,
        min_num = need_discard,
        max_num = need_discard,
        include_equip = false,
        cancelable = false,
        prompt = string.format("惯性：请弃置%d张手牌", need_discard),
      })
      data.phase_end = true
    end
  end,
})

return wen__guanxing